package com.cy.pj.dao;

import com.cy.pj.notice.dao.SysNoticeDao;
import com.cy.pj.notice.pojo插件lombok注解代替set和get方法.SysNotice;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
public class SysNoticeDaoTests数据持久层测试 {
@Autowired
//将自己写的实现类
//@Qualifier("sysNoticeDaolmpl当Dao接口没mapper备注时实现Dao")
private SysNoticeDao sysNoticeDao;

@Test //模糊查询数据
void testSelectNotices(){
    SysNotice notice=new SysNotice();
//notice.setTitle("%my%");
List<SysNotice> list=sysNoticeDao.selectNotices(notice);
for(SysNotice n:list){
    System.out.println(n);
}
}

@Test //新增数据
    void testInsertNotice(){
    SysNotice notice=new SysNotice();
    notice.setTitle("MyBaits SQL映射");
    notice.setContent("反对和恢复");
    notice.setType("1");
    notice.setStatus("0");
    notice.setRemark("学习过程中");
    notice.setCreatedUser("tony");
    notice.setModifiedUser("tony");
sysNoticeDao.insertNotice(notice);
    System.out.println("好了");
}

@Test  //多值删除
void testDeleteById(){
    sysNoticeDao.deleteById(1L,2L,3L,4L,5L,6L,7L,8L,9L,10L);
}

@Test
void testUpdateNotice(){
    //先从表中找出要改的数据
    SysNotice notice=sysNoticeDao.findById(11L);
    notice.setContent("晚上开讲");
     notice.setModifiedUser("奇雷老师");
     sysNoticeDao.updateNotices(notice);
}
}
